perm filename AL.PAL[AL,HE] blob sn#646127 filedate 1982-03-02 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00003 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	.TITLE  AL INTERPRETER
C00006 00003	 program initialization
C00015 ENDMK
C⊗;
.TITLE  AL INTERPRETER

;Need to assemble /H so PALX allocates enough symbol table space

.OFFSET -160000		;Load us into the high mem: virtual 0 → physical 160 000
			;Comtab and dpatch area are in data space
.IFNDF CPOINTY
CPOINTY==0		; unless otherwise stated this is not a POINTY compilation
.ENDC

;These need only be looked at during the first pass:
    .IF1
        .INSRT ALHEAD.PAL[AL,HE]
        .INSRT K1DEF.PAL[11,SYS]
	STSW  KERNEL,1	;1 => use the kernel
    .ENDC

.OFFSET -340000		;Load us into the zonker: virtual 0 → physical 340 000
			;Start and ipatch area are in code space

	;If DDT sends us to user I Space this will start the Kernel up anyway
. = START

	RESTRT		;EMT gets us into Kernel I space
	BPT
	BPT		;This is the INIT entry point to the Kernel

. = INTCOD
CKDE$ == INTCOD		;Interpreter code & data spaces start here
DATA$ == INTDAT
SPSWITCH == 0		;Make sure we start off with everyone properly defined
DATA

.PRINT /	ALIO
/
.IFZ CPOINTY
.INSRT ALIO.PAL[AL,HE]
.IFF
.INSRT ALIO2.PAL[PNT,HE]
.ENDC

.PRINT /	LARGEB
/
.INSRT LARGEB.PAL[AL,HE]

			;Small block allocator
.PRINT /	SMALLB
/
.INSRT SMALLB.PAL[AL,HE]

			;The interpreter
.PRINT /	INTERP
/
.INSRT INTERP.PAL[AL,HE]

.IFNZ CPOINTY		; interpreter for pointy routines
.PRINT /	PINTRP
/
.INSRT PINTRP.PAL[PNT,HE]

			; display routines on the  VT05
.PRINT /	ALDISPLAY
/
.INSRT ALDISP.PAL[PNT,HE]

			; routines talking to the 10
.PRINT /	TALK10
/
.INSRT TALK10.PAL[PNT,HE]
.ENDC
			;The floating I/O
.PRINT /	FLOAT
/
    .INSRT FLOAT.PAL[AL,HE]

			;Graph structure
.PRINT /	GRAPHS
/
.INSRT GRAPHS.PAL[AL,HE]
			;PUMA communications
.PRINT /	VALIO
/
.INSRT VALIO.PAL[AL,HE]
			;Vision Module communications
.PRINT /	VISIO
/
.INSRT VISIO.PAL[AL,HE]


DATA	;Data areas

MAINBL:: PDBLK 1,20	;Makes a process descriptor for main process
MAININ:: PDBLK 1,150,F	;Makes another PDB for the main (1st) interpreter
INTPDB:: PDBLK 2,40	;So we'll have a good stack pointer for interrupts

ISTBLK:: .BLKW ISBS	;Dummy interpreter status block (used in linking only)
PROLST:: .WORD 0	;List of procedures currently active
ALLIVE:: .WORD 0	;1 when AL is running, 0 otherwise, used by POINTY

CODE
temp == %KFFSE	3Save the current offset
.OFFSET 0	;We want to use real Physical addresses here fOp the kernel

	PUTLOC JOBDAT, MAILBL
	PUTLMC JOBSA, AL
	PUTLOA BOBDM, USRDM

.OFFSET temp	;Restkre O`
Mg∃h~∧_vAaI←GeC4AS]Sβ#'π3OSπS'}p4(∀T
1h$hP%o'vKS'πdKk∃β&C∃β←␈∪3⊂4PJ6>Y¬*N.6
A.6εLr
12≥%n7∞[∃βO/∪∃β←*β#π[*β¬β∨}{⊃βO&∂-βε{';S/⊂4(εlzQ↓
+↓AQAdJ:RB$⊃.FB≥8%oπg≠=β;.+⊃β¬∧∧v}}Dλn↑→<]M≡{|H∞>_8zd[|@⊂~w:2y≤8x:9CE	FORK #INTPDB,#INTLUL,#USRDM ;Starp up nulL job - so we'lL hav@∀ABAO=←HAg@~∀&U~IαB~b&.εtJP%nNs'S'∞c'k∃∧K;CW"k?WS∧εW hαB1*jp25∧λts⊃*jα.qn,8H∃
(_p↔[9wv2CEfgUα #STRMES,R0	;Print AL runtime system message
	JSR PC,TYPSTR
	EVSIGCSLEVT	;Release the console
	JSR PC,FRILIT	;Initialize free storage
	JSR PC,SBINIT	;IniTialize small block space
	JSR PC,GSINIT	;@∪]%iSCY%uJAOICaPAMiekGQkeJ~(∪π→$↓∂π≥λ$wπ←k9iKdA→←dAO¬iQKe%]NAM=aGJA⊃CiB~(∪π→%λA-β→=π⊗∩w%]iKe1←GVAUgKHA]QK\A
←[[k9SGCi%]NAo%iPA-¬_~∀∪
→%∧AYβ→∪≥$∩w∪]%iSCY%uJAG=[[k]%GCiS=]fAo%iPA-¬_~∀∪
→$A-5→∨π⊗$w∪]i∃eY←G,AkgK⊂AoQK8AG←[5k]SG¬iS]N↓oSiP↓-SgS=\A≠←⊃kYJ~(∪π→$↓-≠∪≥%(∩w%∀[S]SQSCYSiJAG←5[k]S
CiS←9fAoSQPA-SMS←\A5←IkY∀~∀∪π1$Aβ	1∨π⊗∩m∪]iKIY←GV↓kgKH↓IkeS9NAα←⊂AG←]YKegS=]f~∀$wGQK
VAi↑↓gKJAQQChAQQJA!
∨	
A%fAG←5aCiS	YJ~∀%π≠ AAπ	-HXG!πY%'∪=≤∩w-∃egS←8AG←[ACiSE1J}~∀%¬"@DH∩∩weKf~∀%β→%HA')≠∃&∩w≥<~∀bHh∪∃'$↓!εY∪9∪β%~$vAI↑↓CeZA%]SiS¬YSuCQS←\~(∩wgKPAk`AQQJAM%eghA%]iKeAeKiKH~∀∪∃M$A!ε1∪≥)∪9∪(∩∩m∪]Si%CYSu∀AiQJ↓S]iKIaeKi∃dAKm∃]if~(∪≠∨,G∪'¬LY$`∩$w$`A|A'Su∀@QS\↓o←eILRA←L↓C\AS9iKeaIKiKd↓giCiUfAEY=GV~∀%∃'$AAεY∂)→%
∩$w$`A|A→∨πm]KnA%]iKeAeKiKHAgiCQkfAE1←GW:4∀∪≠∨XA$`YLK	;Prime the interpreter list.
	CLR NXTINT(R0)
	CLR PROLST		;Prime the active procedure list
	MOV #PCODE,IPC(R0)	;new IPC ← interpreter start address
	EVMAK			;-(SP) ← event for EVT in this interpreter
	MOV (SP),EVT(R0)	;new EVT ← event just created.
	MOV R0,-(SP)		;Save LOC[new interpreter status block]
	MOV #INSTSZ,R0		;R0 ← Size needed for an interpreter stack
	JSR PC,GTFREE		;R0 ← LOC[new interpreter stack]
	MOV (SP)+,R1		;R1 ← LOC[new interpreter status block]
	MOV R0,STKBAS(R1)	;Store away new stack base
	ADD #2*INSTSZ,R0	;R0 ← LOC[top of new stack] (INSTSZ is in bytes)
	MOV #MAININ,R2		;R2 ← LOC[main interpreter process descriptor]
	BIS #UGRSAV+USKSAV,PDBSTA(R2)	;Use saved registers so we can set things up
	MOV R0,PDBR3(R2)	;Store away new interp stack pointer (reg 3)
	MOV R2,PDB(R1)		;Store away LOC[PDB] in new ISB
	MOV R1,PDBR4(R2)	;Store away LOC[ISB] in reg 4 of PDB
	MOV USKMAX(R2),USKP(R2)	;Make sure we have a good stack pointer
	SCHEDU R2,#INTERP,#USRDM,#2 ;Cause the new process to be started, suspended
.IFNZ CPOINTY
	MOV #1,ALLIVE		;Let rest of world know we are alive
	JSR PC,@LUNCALIB	; to reestablish calibration
	CMP #1,SAILID		;Is is a POINTY version?
	BNE 42$		;No, no need to start up POINTY
	JSR PC,UPDINIT		;Initialize the updating
	JSR PC,PNTINIT	;Yes, go initialize POINTY
42$:
.ENDC
	EVWAIT 		;Wait for the return signal
	BCC  5$		;All well?
	ALERR TSTMES	;No
5$:
.IFNZ CPOINTY
	CMP #1,SAILID		;is it pointy?
	BNE 51$
	CLR ALLIVE	;done with the AL program
	SLEEP #1000.	;give a chance for all the other jobs to die
51$:
.ENDC
	TST LFINARM	;For debugging new systems - if the arm code hasn't been
	BEQ 6$		; loaded then don't try to turn off the arm servo
	JSR PC,@LFINARM	;Finished with the arm code
6$:	EVWAIT CSLEVT	;Grab the console
	MOV #ENDMES,R0	;Print ALL DONE message
	JSR PC,TYPSTR
	GETTIM		;Get current time from kernel
	CLRB 1(SP)	;So we don't lose the lower bits on conversion
	SETL		;Time is in long format
	LDCLF (SP)+,AC0	;AC0 ← time in msecs
	SETI		;Back to normal short integer format
	DIVF THOUS,AC0	;AC0 ← time in seconds
	MOV #OUTBUF,R0
	JSR PC,CVFX
	MOV #OUTBUF,R0
	JSR PC,TYPSTR	;Tell how long we took
	MOV #TIMMES,R0
	JSR PC,TYPSTR
	EVSIG CSLEVT	;Release the console
	DISMIS		;Go away


INIARM:	TST LINTARM	;For debugging new systems - if the arm code hasn't been
	BEQ 4$		; loaded then don't try to initialize the arm
	MOV #5*DVBKSZ,R0 ;Get a BIG device block
	JSR PC,GTFREE
	MOV R0,R1
	MOV R0,-(SP)	;Save address of device block so we can free it
	JSR PC,@LINTARM	;Initialize the arm code
	TST R0		;All well?
	BEQ 3$		;Yes
	CMP R0,#10	;Is it the reference supply?
	BNE 2$
	ALERR STMES3	; yup - complain about it.
	BR 3$
2$:	CMP R0,#7	;Is it the power supply?
	BNE 22$
	ALERR STMES4	; yup - complain about it.
	BR 3$
22$:	ALERR STMES2	;Just make a general complaint.
3$:	MOV (SP)+,R0	;R0 ← LOC[device block]
	JSR PC,RLFREE	;Release it
	CMP ARMVER,#VERSION	;Arm compatible?
	BEQ 4$		;Yes
	ALERR STMES1	;No
4$:	RTS PC

INTNUL:	MOV USKMAX+INTPDB,SP	;Make sure we have a good stack pointer
	DISMIS			;Now go away

DATA
PNTMES:: ASCIE </CAN'T CONTINUE/>
STMES::  ASCIE </INCOMPATIBLE PCODE VERSION.  PROCEED AT YOUR OWN RISK/>
STMES1:: ASCIE </INCOMPATIBLE ARM VERSION.  PROCEED AT YOUR OWN RISK/>
STMES2:: ASCIE </CAN'T INITIALIZE ARM.  ERROR CODE IN R0./>
STMES3:: ASCIE </CAN'T INITIALIZE ARM.  REFERENCE POWER SUPPLY OUT OF RANGE./>
STMES4:: ASCIE </Can't initialize arm.  Interface power supply turned off/>
TSTMES:: ASCIE </BAD RETURN FROM MAIN INTERPRETER/>
STRMES:: ASCIE </
AL runtime system

/>
TIMMES:: ASCIE </ SECONDS
/>
ENDMES:: ASCIE </

ALL DONE NOW.  SEE YOU AROUND!
ELAPSED TIME = />

DATEND == .		;Get end of data address

.IF2
DATA
CODE
	.INFO <First location after interpreter code = 340000 + >,\CODE$
	    .IFL 120000 - CODE$
	      .PRINT /Now need to dump above 460000 with 11TTY!
/
	    .ENDC
	    .IFL 140000 - CODE$
	      .ERROR Interpreter code too large for available memory!
	    .ENDC
	.INFO <Data ends at = >,\DATA$

	foo == <PCODE - DATEND - 3> / <4 * 60.>	; # of seconds we can gather
	.INFO <Gather buffer in seconds (base 8) = >,\foo
.ENDC

.END  START